package com.tour.modules.web.controller.api;

import java.util.HashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.tour.common.utils.R;
import com.tour.modules.web.entity.TCityEntity;
import com.tour.modules.web.service.TCityService;

import javax.servlet.http.HttpServletRequest;

@Controller
public class TCityApi {
	@Autowired
	private TCityService tCityService;
	
	@RequestMapping("/api/tcity/list")
	@ResponseBody
	public R list(){
		List<TCityEntity> tCityList = tCityService.queryList(new HashMap<String, Object>());
		return R.ok().put("cityList", tCityList);
	}
	@RequestMapping("/api/tcity/info")
	public String info(HttpServletRequest request){
		TCityEntity tCityEntity=tCityService.queryObject(Long.parseLong(request.getParameter("id")));
		if(tCityService==null){
			return null;
		}
		request.getSession().setAttribute("city",tCityEntity);
		return "redirect:/front/city.jsp";
	}
}
